//
//  ISetMeal.m
//  XRmenu
//
//  Created by yangxh on 11-3-24.
//  Copyright 2011 E0571. All rights reserved.
//

#import "ISetMeal.h"


@implementation ISetMeal

@synthesize name;
@synthesize setMealId;
@synthesize summary;
@synthesize spellCode;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
	return [self initWithName:nil setMealId:nil summary:nil];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithName:(NSString*)aName setMealId:(NSString*)aSetMealId summary:(NSString*)aSummary 
{
    self = [super init];
    if (self) {
        self.name = aName;
        self.setMealId = aSetMealId;
        self.summary = aSummary;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithName:(NSString*)aName setMealId:(NSString*)aSetMealId summary:(NSString*)aSummary  
{
    id result = [[[self class] alloc] initWithName:aName setMealId:aSetMealId summary:aSummary];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"name",
					   @"setMealId",
					   @"summary",
					   @"spellCode",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [name release];
    name = nil;
    [setMealId release];
    setMealId = nil;
    [summary release];
    summary = nil;
	[spellCode release];
	spellCode = nil;
	
    [super dealloc];
}

+ (ISetMeal *)iSetMealByParse:(NSDictionary *)info
{
	ISetMeal *setMeal = [ISetMeal objectWithName:dictObject(info,@"Name")
									   setMealId:dictObject(info,@"SetMealId")
										 summary:dictObject(info,@"Summary")];
	setMeal.spellCode = dictObject(info,@"SpellCode");
	return setMeal;
}

@end
